function startTimeTest() {
    var num=$('#numinput').val();
    var page=$('#pagesel').val();
    var version=$('input:radio[name="version"]:checked').val();
    $.ajax({
			type: "POST",
			url: "/androidtest/startTimeTest/",
			contentType: "application/json",
			data: JSON.stringify({
				"num": num,
				"page": page,
				"version":version
			}),
			beforeSend: function () {
				layer.load(0, {shade: [0.4, '#E8E8E8', true]});
			},
			success: function (rsp) {
				console.log(rsp);
				layer.alert('启动时间测试完成！', {
					icon: 6,
					skin: 'layer-ext-moon'
                 });
			},
			complete: function () {
				layer.closeAll('loading');
            },
            error: function (data) {
				console.info("error: " + data.responseText);
            }
		})
}

function serachStartResult(){
	 $.ajax({
			type: "POST",
			url: "/androidtest/startTimeResult/",
			contentType: "application/json",
			beforeSend: function () {
				layer.load(0, {shade: [0.4, '#E8E8E8', true]});
			},
			success: function (rsp) {
				console.log(rsp);
				var data = $.parseJSON(rsp);
				var y0=data.model['elapsed01'];
				var y1=data.model['elapsed11'];
				var y2=data.model['elapsed21'];
				var y3=data.model['elapsed00'];
				var y4=data.model['elapsed10'];
				var y5=data.model['elapsed20'];
				var xdata=[];
				var oldavg=[];
				var newavg=[];
				var all0=0;
				var all1=0;
				var all2=0;
				var all3=0;
				var all4=0;
				var all5=0;
				for (var i=0;i<y0.length;i++){
					xdata.push(i+1);
					all0 += parseInt(y0[i]);
					all1 += parseInt(y1[i]);
					all2 += parseInt(y2[i]);
					all3 += parseInt(y3[i]);
					all4 += parseInt(y4[i]);
					all5 += parseInt(y5[i]);
				}
				oldavg=[Math.floor(all3/(y0.length)),Math.floor(all4/(y0.length)),Math.floor(all5/(y0.length))];
				newavg=[Math.floor(all0/(y0.length)),Math.floor(all1/(y0.length)),Math.floor(all2/(y0.length))];

				// 基于准备好的dom，初始化echarts图表
				var myChart = echarts.init(document.getElementById("dataMain"));
				var option = {
                    title: {
                        text: '新版本启动时间折线图',
                        subtext: ''
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: ['启动页','登录页','首页']
                    },
                    //右上角工具条
                    toolbox: {
                        show: true,
                        feature: {
                            //mark: {show: true},
                            //dataView: {show: true, readOnly: false},
                            magicType: {show: true, type: ['line', 'bar']},
                            //restore: {show: true},
                            saveAsImage: {show: true}
                        }
                    },
                    calculable: true,
                    xAxis: [
                        {
                            type: 'category',
                            boundaryGap: false,
                            data: xdata
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            axisLabel: {
                                formatter: '{value}'
                            }
                        }
                    ],
					series : [
						{
							name:'启动页',
							type:'line',
							data:y0,
							markPoint : {
								data : [
									{type : 'max', name: '最大值'},
									{type : 'min', name: '最小值'}
								]
							},
							markLine : {
								data : [
									{type : 'average', name: '平均值'}
								]
							}
						},
						{
							name:'登录页',
							type:'line',
							data:y1,
							markPoint : {
								data : [
									{type : 'max', name: '最大值'},
									{type : 'min', name: '最小值'}
								]
							},
							markLine : {
								data : [
									{type : 'average', name: '平均值'}
								]
							}
						},
						{
							name:'首页',
							type:'line',
							data:y2,
							markPoint : {
								data : [
									{type : 'max', name: '最大值'},
									{type : 'min', name: '最小值'}
								]
							},
							markLine : {
								data : [
									{type : 'average', name: '平均值'}
								]
							}
						},
					]
                }

				// 为echarts对象加载数据
				myChart.setOption(option);

				var myChart2 = echarts.init(document.getElementById("dataMain2"));
				var option2 = {
					title: {
                        text: '新旧版本启动时间对比柱形图',
                        subtext: ''
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
						show: true,
						x: 'center',
						y: 'top',
                        data: ['旧版本','新版本']
                    },
                    //右上角工具条
                    toolbox: {
                        show: true,
                        feature: {
                            //mark: {show: true},
                            //dataView: {show: true, readOnly: false},
                            //magicType: {show: true, type: ['line', 'bar']},
                            //restore: {show: true},
                            saveAsImage: {show: true}
                        }
                    },
                    calculable: true,
					  //设置坐标轴
					  xAxis : [
						{
						  type : 'category',
						  data : ["启动页","登录页","首页"]
						}
					  ],
					  yAxis : [
						{
						  type : 'value'
						}
					  ],
					  //设置数据
					  series : [
						{
						  "name":"旧版本",
						  "type":"bar",
						  "data":oldavg,
						},
						{
						  "name":"新版本",
						  "type":"bar",
						  "data":newavg,
						}
					  ]
					};
				myChart2.setOption(option2);



			},
			complete: function () {
				layer.closeAll('loading');
            },
            error: function (data) {
				console.info("error: " + data.responseText);
            }
		})
}

